Structure of a script

Script’s structure depends on the language you use; however there are some common elements. They are the script’s title, body, and the main procedure, which will be executed when the report runs. Below there are examples of the scripts for all four supported languages:

PascalScript’s structure:

#language PascalScript // optional
program MyProgram; // optional
// the "uses" chapter should be located before any other chapter
uses 'unit1.pas', 'unit2.pas';
var // the "variables" chapter can be placed anywhere
i, j: Integer;
const // "constants" chapter pi = 3.14159;
procedure p1; // procedures and functions
var
i: Integer;
procedure p2; // nested procedure
begin
end;
begin
end;
begin // main procedure.
end.

C++Script’s structure:

#language Ñ++Script // optional
// the "include" chapter should be placed before any other chapter
#include "unit1.cpp", "unit2.cpp"
int i, j = 0; // the "variables" chapter can be placed anywhere
#DEFINE pi = 3.14159 // "constants" chapter
void p1() // functions
{ // no nested procedures
}
{ // main procedure.
}

BasicScript’s structure:

#language BasicScript // optionally
// the "imports" chapter should be located before any other chapter
imports "unit1.vb", "unit2.vb"
dim i, j = 0 // the "variables" chapter can be placed anywhere
function p1() // functions
{ //
}
// main procedure.
for i = 0 to 10
p1()
next

More detailed description of the FastScript script engine can be found in its documentation. The author did not duplicate the following moments in the manual:
- syntactic diagrams of all the supported languages;
- supported data types;
- operations with classes, properties, methods, and events;
- nested functions;
- enumerations and sets.

Later, we will examine examples of scripts written in "PascalScript" language. As soon as a new report is created, this language is selected by default.